home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Softquad / hm2.solaris.tar / hm2 / bin / mkfontsrc < prev   
Text File  |  1996-01-18  |  3KB  |  152 lines

  1. #! /bin/sh
  2. #
  3. # Shell script to build an A/E 2.1 fontsrc file.
  4. #
  5. # You must be running the X Window system (or OpenWindows or DECWindows, etc)
  6. # in order for this to works, as i has to contact your X display server.
  7. #
  8. # Copyright SoftQuad Inc., 1992
  9. #
  10. # (@)# @(#)mkfontsrc    1.1 92/06/08
  11. #
  12.  
  13. # X font names are in this format:
  14. #-fndry-fam-wt-slant-sWidth-adstyle-pxlsz-ptsz-xres-yres-spc-avgwid-rgstry-enc
  15. # run the xfontsel program to get a feel for this...
  16.  
  17. FONTLIST=${SQDIR-/usr/sqps}/lib/fontlist
  18.  
  19. case "$1" in
  20. [0-9][0-9]*)
  21.     RES=$1
  22.     ;;
  23.  
  24. *)    echo "Usage: $0 screen-resolution (e.g. 75)" 1>&2
  25.     echo $0: output will be in ${DISPLAY-"$DISPLAY"}.fontsrc 1>&2
  26.     exit 1
  27.     ;;
  28. esac
  29.  
  30.  
  31. if test ! -f "$FONTLIST"
  32. then
  33.     echo "$0: could not open fontlist [\$SQDIR=$SQDIR]" 1>&2
  34.     cat "$FONTLIST" > /dev/null # make an error message
  35.     exit 1
  36. fi
  37.  
  38. if test x"$DISPLAY" = x""
  39. then
  40.     echo "$0: you must set the DISPLAY variable to your X Windows display" 1>&2
  41.     exit 1
  42. else
  43.     echo "$0: making fontsrc for X display $DISPLAY..." 1>&2
  44. fi
  45.  
  46. NAWK=
  47.  
  48. set `echo $PATH | tr ':' ' '`
  49.  
  50. for i
  51. do
  52.     if test -f "$i/mawk"
  53.     then NAWK="$i/mawk"
  54.      break
  55.     fi
  56. done
  57.  
  58. if [ x"$NAWK" = x"" ]
  59. then
  60.     for i
  61.     do
  62.     if test -f "$i/nawk"
  63.     then NAWK="$i/nawk"
  64.          break
  65.     elif test -f "$i/gawk"
  66.     then NAWK="$i/gawk"
  67.          break
  68.     fi
  69.     done
  70. fi
  71.  
  72. if [ x"$NAWK" = x"" ]
  73. then
  74.     NAWK=awk
  75. fi
  76.  
  77. xlsfonts | fgrep -f $FONTLIST | grep -v .0-0-. |
  78.     sort -t- +1 | # sort on font family, not foundry
  79.     $NAWK -F- '
  80.  
  81. #font format:
  82. #-fndry-fam-wt-slant-sWidth-adstyle-pxlsz-ptsz-xres-yres-spc-avgwid-rgstry-enc
  83.  
  84. BEGIN {
  85.     Sizes[8] = 8
  86.     Sizes[10] = 10
  87.     Sizes[12] = 12
  88.     Sizes[14] = 14
  89.     Sizes[18] = 18
  90.     Sizes[24] = 24
  91.     Res = '"${RES}"' + 0
  92. }
  93.  
  94. (NF != 15) {
  95.     # printf "Ignore (%d fields not 15): %s\n", NF, $0 | "cat 1>&2"
  96.     next # malformed font name
  97. }
  98.  
  99. ($(10) != $(11)) {
  100.     printf "Aspect ratio unknown: %s\n", $0 | "cat 1>&2"
  101.     next
  102. }
  103.  
  104. {
  105.     Size = $9 / 10
  106.     if (Sizes[Size] + 0 > 0) {
  107.     Face = "p"
  108.     } else {
  109.     # printf "Size %d unknown in %s\n", Size, $0 | "cat 1>&2"
  110.     next
  111.     }
  112.  
  113.     if ($(11) > Res * 1.1 || $(11) < Res * 0.9) {
  114.     if ($11 == 100 || $10 == 75) next
  115.     printf "Resolution %d not %d in %s\n", $(11), Res, $0 | "cat 1>&2"
  116.     next # wrong resolution
  117.     }
  118. } # default
  119.  
  120. ($5 == "i" || $5 == "o") {
  121.     Face = "i"
  122. } # italic or oblique
  123.  
  124. ($4 == "bold" || $4 == "demi" || $4 == "demibold") {
  125.     if (Face == "p") Face = "b"
  126.     else Face = "bi"
  127. }
  128.  
  129. {
  130.     Family = $3
  131.     if ($6 != "" && $6 != "normal") Family = Family " " $6
  132.  
  133.     if (FamiliesSeen[Family] == "") {
  134.     FamiliesSeen[Family] = $2
  135.     } else if (FamiliesSeen[Family] != $2) {
  136.     Family = $2 " " Family
  137.     }
  138.  
  139.     printf "FONT : %s : %s : %-02.02d : ", Family, Face, Size
  140.  
  141.     for (i = 1; i <= NF; i = i + 1) { # awk does not have ++, blame dns
  142.     printf "%s", $i
  143.     if (i < NF) printf "-"
  144.     }
  145.     printf "\n"
  146. }
  147.  
  148. ' > "$DISPLAY".fontsrc
  149.  
  150. echo "$0: output is in $DISPLAY.fontsrc:"
  151. /bin/ls -l "$DISPLAY".fontsrc
  152.